﻿using System;
using System.ComponentModel;

namespace HalconDotNet
{
	/// <summary>Represents an instance of a barrier synchronization object.</summary>
	// Token: 0x0200001A RID: 26
	public class HBarrier : HHandle
	{
		// Token: 0x06000190 RID: 400 RVA: 0x0000883B File Offset: 0x00006A3B
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HBarrier() : base(HHandleBase.UNDEF)
		{
		}

		// Token: 0x06000191 RID: 401 RVA: 0x000093C4 File Offset: 0x000075C4
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HBarrier(IntPtr handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x06000192 RID: 402 RVA: 0x000093D3 File Offset: 0x000075D3
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HBarrier(HHandle handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x06000193 RID: 403 RVA: 0x000093E2 File Offset: 0x000075E2
		private void AssertSemType()
		{
			base.AssertSemType("barrier");
		}

		// Token: 0x06000194 RID: 404 RVA: 0x000093EF File Offset: 0x000075EF
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HBarrier obj)
		{
			obj = new HBarrier(HHandleBase.UNDEF);
			return obj.Load(proc, parIndex, err);
		}

		// Token: 0x06000195 RID: 405 RVA: 0x00009408 File Offset: 0x00007608
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HBarrier[] obj)
		{
			HTuple htuple;
			err = HTuple.LoadNew(proc, parIndex, err, out htuple);
			obj = new HBarrier[htuple.Length];
			for (int i = 0; i < htuple.Length; i++)
			{
				obj[i] = new HBarrier(HalconAPI.IsLegacyHandleMode() ? htuple[i].IP : htuple[i].H);
			}
			htuple.Dispose();
			return err;
		}

		/// <summary>
		///   Create a barrier synchronization object.
		///   Modified instance represents: Barrier synchronization object.
		/// </summary>
		/// <param name="attribName">Barrier attribute. Default: []</param>
		/// <param name="attribValue">Barrier attribute value. Default: []</param>
		/// <param name="teamSize">Barrier team size. Default: 1</param>
		// Token: 0x06000196 RID: 406 RVA: 0x00009478 File Offset: 0x00007678
		public HBarrier(HTuple attribName, HTuple attribValue, int teamSize)
		{
			IntPtr proc = HalconAPI.PreCall(552);
			HalconAPI.Store(proc, 0, attribName);
			HalconAPI.Store(proc, 1, attribValue);
			HalconAPI.StoreI(proc, 2, teamSize);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(attribName);
			HalconAPI.UnpinTuple(attribValue);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Create a barrier synchronization object.
		///   Modified instance represents: Barrier synchronization object.
		/// </summary>
		/// <param name="attribName">Barrier attribute. Default: []</param>
		/// <param name="attribValue">Barrier attribute value. Default: []</param>
		/// <param name="teamSize">Barrier team size. Default: 1</param>
		// Token: 0x06000197 RID: 407 RVA: 0x000094E0 File Offset: 0x000076E0
		public HBarrier(string attribName, string attribValue, int teamSize)
		{
			IntPtr proc = HalconAPI.PreCall(552);
			HalconAPI.StoreS(proc, 0, attribName);
			HalconAPI.StoreS(proc, 1, attribValue);
			HalconAPI.StoreI(proc, 2, teamSize);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Destroy a barrier synchronization object.
		///   Instance represents: Barrier synchronization object.
		/// </summary>
		// Token: 0x06000198 RID: 408 RVA: 0x0000953C File Offset: 0x0000773C
		public void ClearBarrier()
		{
			IntPtr proc = HalconAPI.PreCall(550);
			base.Store(proc, 0);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Wait on the release of a barrier synchronization object.
		///   Instance represents: Barrier synchronization object.
		/// </summary>
		// Token: 0x06000199 RID: 409 RVA: 0x00009570 File Offset: 0x00007770
		public void WaitBarrier()
		{
			IntPtr proc = HalconAPI.PreCall(551);
			base.Store(proc, 0);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Create a barrier synchronization object.
		///   Modified instance represents: Barrier synchronization object.
		/// </summary>
		/// <param name="attribName">Barrier attribute. Default: []</param>
		/// <param name="attribValue">Barrier attribute value. Default: []</param>
		/// <param name="teamSize">Barrier team size. Default: 1</param>
		// Token: 0x0600019A RID: 410 RVA: 0x000095A4 File Offset: 0x000077A4
		public void CreateBarrier(HTuple attribName, HTuple attribValue, int teamSize)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(552);
			HalconAPI.Store(proc, 0, attribName);
			HalconAPI.Store(proc, 1, attribValue);
			HalconAPI.StoreI(proc, 2, teamSize);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(attribName);
			HalconAPI.UnpinTuple(attribValue);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Create a barrier synchronization object.
		///   Modified instance represents: Barrier synchronization object.
		/// </summary>
		/// <param name="attribName">Barrier attribute. Default: []</param>
		/// <param name="attribValue">Barrier attribute value. Default: []</param>
		/// <param name="teamSize">Barrier team size. Default: 1</param>
		// Token: 0x0600019B RID: 411 RVA: 0x0000960C File Offset: 0x0000780C
		public void CreateBarrier(string attribName, string attribValue, int teamSize)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(552);
			HalconAPI.StoreS(proc, 0, attribName);
			HalconAPI.StoreS(proc, 1, attribValue);
			HalconAPI.StoreI(proc, 2, teamSize);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}
	}
}
